package com.dht.xiao.jianye.base.mqtt.log;

import com.dht.xiao.jianye.base.util.CommonUtil;

/**
 * @author :      fangbingran
 * @aescription : todo(这里用一句话描述这个类的作用)
 * @date :        2019/06/13  20:13
 */
public class MqttLoggerFactory {
    private static MqttLogger mMqttLogger;

    public MqttLoggerFactory() {
    }

    public static void createLogger(MqttLogger mqttLogger) {
        mMqttLogger = mqttLogger;
    }

    public static void debug(String logger) {
        if (mMqttLogger != null) {
            mMqttLogger.debug(logger);
        }

    }

    public static void info(String logger) {
        if (mMqttLogger != null) {
            mMqttLogger.info(logger);
        }

    }

    public static void warn(String logger) {
        if (mMqttLogger != null) {
            mMqttLogger.warn(logger);
        }

    }

    public static void warn(String logger, Throwable throwable) {
        if (mMqttLogger != null) {
            mMqttLogger.warn(logger, CommonUtil.getThrowableStrRep(throwable), throwable);
        }

    }

    public static void error(String logger) {
        if (mMqttLogger != null) {
            mMqttLogger.error(logger);
        }

    }

    public static void error(String logger, Throwable throwable) {
        if (mMqttLogger != null) {
            mMqttLogger.error(logger, CommonUtil.getThrowableStrRep(throwable), throwable);
        }

    }
}
